package weaver.interfaces.jjy.duss.action;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/*
 *@Description: 福利人员上报回退接口
 *@Author: Dusongsong
 *@Date: 2019/12/24
 */
public class WeaHRflryhtAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {

        RecordSet rs = new RecordSet();
        RecordSet rs2 = new RecordSet();
        BaseBean baseBean = new BaseBean();
        String requestid = requestInfo.getRequestid();
        baseBean.writeLog("请求ID" + requestid);
        baseBean.writeLog("调用: WeaHRflryhtAction");
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        rs.executeQuery("select id from " + tablename + " where requestid=?", requestid);
        baseBean.writeLog("select id from " + tablename + " where requestid=?" + requestid);
        rs.next();
        String mainid = Util.null2String(rs.getString("id"));//外键
        String STATE = "0";
        try {
            rs.executeQuery("select numid  from " + tablename + "_dt1 where mainid='" + mainid + "' ");
            while (rs.next()) {
                String NUMID = Util.null2String(rs.getString("NUMID"));//唯一标识
                rs2.execute("select flfw1,flkh from " + tablename + "_dt1 where mainid='" + mainid + "' and numid='" + NUMID + "'");
                rs2.next();
                baseBean.writeLog("调用SQL：" + "select flfw1,flkh from " + tablename + "_dt1 where mainid='" + mainid + "'and  numid='" + NUMID + "'");
                rs2.executeUpdate("update uf_sxflrymdxf set flfw1='' ,flkh1= '', zt='" + STATE + "' where  numid='" + NUMID + "'");
                baseBean.writeLog("执行语句：" + "update uf_sxflrymdxf set flfw1='' ,flkh1= '', zt='" + STATE + "' where  numid='" + NUMID + "'");
            }
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            baseBean.writeLog("异常参考:" + e);
            requestInfo.getRequestManager().setMessageid("111111");
            requestInfo.getRequestManager().setMessagecontent(e.getMessage());
            return Action.FAILURE_AND_CONTINUE;
        }

    }
}

